package com.southpark.system.managers
{
	import com.southpark.system.enum.CookieNameEnum;
	import com.southpark.system.interfaces.managers.IApplicationManager;
	import com.southpark.system.interfaces.managers.ICookieManager;
	
	import flash.net.SharedObject;


	
	public class CookieManager implements ICookieManager
	{
		
		public function CookieManager(applicationManager:IApplicationManager)
		{
			this.applicationManager = applicationManager;
			sharedObject = SharedObject.getLocal(applicationManager.applicationName);
		}
		
		
		/**
		 * 
		 */
		private var applicationManager:IApplicationManager;
		private var sharedObject:SharedObject;
		
		public function getCookie(cookieName:CookieNameEnum):String
		{
			return sharedObject.data[cookieName.itsString];
		}
		
		public function setCookie(cookieName:CookieNameEnum,value:String):void
		{
			sharedObject.data[cookieName.itsString] = value;
     		sharedObject.flush();
		}
		
		public function deleteAllCookies():void
		{
			sharedObject.clear();
		}
		
		
	}
}